package main

import (
	"Junior_two/subject/cart/cartrpc/model"
	"Junior_two/subject/cart/cartrpc/utils"
	"fmt"
	"github.com/astaxie/beego/orm"
)

func main() {
	//连接mysql 进行 获取商品的库存
	var g []model.Goods
	o := orm.NewOrm()
	o.QueryTable("goods").All(&g)
	for _, v := range g {
		count := v.Num
		LKey := "Number:good_id" + fmt.Sprintf("%d", v.Id)
		if count > 0 {
			for i := 1; i <= int(count); i++ {
				//备份 redis 库存
				utils.RedisLPush(LKey)
			}
		}
	}
}
